import request from "@/utils/request";

export default {
  getReceiveGoodsList(searchModel) {
    return request({
      url: "/receiveGoods/list",
      method: "get",
      params: {
        oddNumber: searchModel.oddNumber,
        serialNumber: searchModel.serialNumber,
        type: searchModel.type,
        createTime: searchModel.createTime,
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
      },
    });
  },

  addReceiveGoods(receiveGoods) {
    return request({
      url: "/receiveGoods",
      method: "post",
      data: receiveGoods,
    });
  },

  getReceiveGoodsById(id) {
    return request({
      url: `/receiveGoods/${id}`,
      method: "get",
    });
  },

  saveReceiveGoods(receiveGoods) {
    if (receiveGoods.id == null && receiveGoods.id == undefined) {
      return this.addReceiveGoods(receiveGoods);
    }
    return this.updateReceiveGoods(receiveGoods);
  },

  updateReceiveGoods(receiveGoods) {
    return request({
      url: `/receiveGoods`,
      method: "put",
      data: receiveGoods,
    });
  },

  deleteReceiveGoodsById(id) {
    return request({
      url: `/receiveGoods/${id}`,
      method: "delete",
    });
  },
};
